import request from "@/utils/request";
import { param } from "@/utils";
/**
 * 预收款单列表
 */
export const getList = (query, data) => {
  return request({
    url: `/finance/receipt/page?${param(query)}`,
    method: "post",
    data
  });
};
/**
 * 删除预收款单
 */
export const del = slipId => {
  return request({
    url: `/finance/receipt/remove/${slipId}`
  });
};
/**
 * 去支付
 */
export const pay = data => {
  return request({
    url: `/finance/receiptRecord/receipt`,
    method: "post",
    data
  });
};
/**
 * 总数
 */
export const getCount = data => {
  return request({
    url: `/finance/receipt/getCount`,
    method: "post",
    data
  });
};
/**
 * 根据类型查询合作方列表
 */
export const getPartnerList = (type, value) => {
  return request({
    url: `/finance/partner/getCustomerByType`,
    params: { type, value }
  });
};

/**
 * 批量支付
 */
export const batchPay = data => {
  return request({
    url: `/finance/receiptRecord/batchReceipt`,
    method: "post",
    data
  });
};
/**
 * 详情
 */
export const detail = slipId => {
  return request({
    url: `/finance/receipt/detail/${slipId}`
  });
};

/**
 * 预收款分类树
 */
export const getAdvancePaymentTree = () => {
  return request({
    url: "/finance/billCategory/earnest/tree"
  });
};
/**
 * 意向金分类更新
 */
export const updateCategory = data => {
  return request({
    url: "/finance/receipt/earnest/update",
    method: "post",
    data
  });
};
/**
 * 导出
 */
export const exportTableData = (query, data) => {
  return request({
    url: `/finance/receipt/download?${param(query)}`,
    method: "post",
    data,
    responseType: "blob"
  });
};

/**
 * 导出调拨单
 */
export const exportAllocation = (query, data) => {
  return request({
    url: `/finance/slipApply/download?${param(query)}`,
    method: "post",
    data,
    responseType: "blob"
  });
};
/**
 * 付款单、收款单详情--混合支付
 */
export const paymentsDetail = data => {
  return request({
    url: `/finance/batch_payment/prepare_batch_payments`,
    method: "post",
    data
  });
};
/**
 * 付款单、收款单提交--混合支付
 */
export const batchPayments = data => {
  return request({
    url: `/finance/batch_payment/batch_process_payments`,
    method: "post",
    data
  });
};
